# Qt5 从项目中下载编译太慢了，需要预编译好后，直接在项目中引用

if (OS_LINUX)
  set(Qt5_DIR "/usr/local/Qt-5.15.6/lib/cmake/Qt5")
endif()

# =============================================================================
# Find packages: Qt
macro(find_qt)
  set(CMAKE_AUTOMOC ON)
  set(CMAKE_AUTORCC ON)
  set(CMAKE_AUTOUIC ON)
  set(CMAKE_AUTOUIC_SEARCH_PATHS ${PROJECT_SOURCE_DIR}/ui)
  find_package(Qt5 COMPONENTS REQUIRED ${ARGV})
endmacro(find_qt)

function(use_qt ag_project_name)
  target_include_directories(${ag_project_name} PRIVATE ${Qt5_DIR}/../../../include/QtCore/5.15.6)
  target_include_directories(${ag_project_name} PRIVATE ${Qt5_DIR}/../../../include/QtGui/5.15.6)
  target_compile_definitions(${ag_project_name} PRIVATE USE_LIB_QT5)
  target_link_libraries(${ag_project_name} PRIVATE ${ARGN})
endfunction(use_qt)